﻿package com.pandemicode.framework.utils {
	/**
	* @author Michael Lawrence
	* @version 1.0.0
	*/
	public class ObjectHelper {
		/**
		 * A series of methods for dealin with objects.
		 */
		public function ObjectHelper() { }
		
		/**
		 * Traces and iterates an object.
		 * @param	o		The object to iterate and trace.
		 * @param	prop	The name of the property.
		 * @param	depth	The depth of the trace. This is how many tabs will be shown.
		 */
		public static function traceObject(o:Object, prop:String, depth:Number = 0):void {
			switch(typeof(o)) {
				case "array":
					trace(StringUtils.padLeft(prop, " ", depth * 5) + " : ");
					for (var i:Number = 0; i < o.length; i++)
						traceObject(o[i], i.toString(), depth + 1);
					break;
				case "object":
					trace(StringUtils.padLeft(prop, " ", depth * 5) + " : ");
					for (var j:String in o)
						traceObject(o[j], j, depth + 1);
					break;
				default:
					trace(StringUtils.padLeft(prop, " ", depth * 5) + " : " + o);
			}
		}
	}
}